/* *
 * 去除抖动
 * */

const DEBOUNCE = {}

export default {
    install(Vue) {

        Object.defineProperty(Vue.prototype.$bui, 'debounce', {
            value: function (cb, time = 300) {
                if (typeof cb !== 'function') return

                const key = cb.toString()

                if (DEBOUNCE[key] === undefined) {
                    DEBOUNCE[key] = setTimeout(() => {
                        cb()
                        delete DEBOUNCE[key]
                    }, time)
                }
            }
        })

    }
}
